/// @tags: DPonTree Exclusion
#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;

namespace BlueQuantum {

typedef long long ll;

int const N = 18;

int n, m, e_cnt;
int heads[N], ban[N];
bool mp[N][N];
ll ans;
ll f[N][N];

struct Edge {
  int v, nxt;
} e[N * N << 1];

inline void add(int u, int v) {
  e[++e_cnt].v = v, e[e_cnt].nxt = heads[u], heads[u] = e_cnt;
}

void dfs(int x, int fa) {
  for (int i = 1; i <= n; ++i) f[x][i] = 1;
  for (int i = heads[x], v; i; i = e[i].nxt) {
    if ((v = e[i].v) != fa) {
      dfs(v, x);
      for (int j = 1; j <= n; ++j) {
        ll sum = 0;
        for (int k = 1; k <= n; ++k) sum += f[v][k] * (mp[k][j] & ban[k] & ban[j]);
        f[x][j] *= sum;
      }
    }
  }
}

inline int main() {
  cin >> n >> m;
  for (int i = 1, u, v; i <= m; ++i) {
    cin >> u >> v;
    mp[u][v] = mp[v][u] = true;
  }
  for (int i = 1, u, v; i < n; ++i) cin >> u >> v, add(u, v), add(v, u);
  for (int sta = 1; sta < 1 << n; ++sta) {
    int cnt = n;
    for (int i = 0; i < n; ++i) {
      ban[i + 1] = (sta >> i) & 1;
      cnt -= ban[i + 1];
    }
    dfs(1, 1);
    for (int i = 1; i <= n; ++i) ans += (cnt & 1) ? -f[1][i] : f[1][i];
  }
  cout << ans;
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("P3349 [ZJOI2016] 小星星.in", "r", stdin);
  freopen("P3349 [ZJOI2016] 小星星.out", "w", stdout);
#endif
#endif

  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
